<?
	session_start();
	require("checksessionadmin.php");
	require("connect.php");
	$chon=$_REQUEST["option"];	
 	switch ($chon){	
		case "Add":
			mysql_query("insert into tobomon_giaovien(matbm,magv,chucvu) values('{$_REQUEST["tobomonid"]}','{$_POST["magv"]}','{$_POST["chucvu"]}')") or die("Kiểm tra lại !");
			break;		
		case "save":
			mysql_query("update tobomon_giaovien set chucvu='{$_REQUEST["chucvu"]}' where matbm='{$_REQUEST["matbm"]}' and magv='{$_REQUEST["magv"]}'") or die("Kiểm tra lại !");
			break;		
		case "xoa":				
			mysql_query("delete from tobomon_giaovien where matbm='{$_REQUEST["matbm"]}' and magv='{$_REQUEST["magv"]}'");			
			break;
	}		
?>
<html><!-- InstanceBegin template="/Templates/admintemplate.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="Javascript" src="../scripts/innovaeditor.js"></script>
<link rel="stylesheet" type="text/css" href="../css/engine.css" />
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<script language="javascript" type="text/javascript" src="../js/datetimepicker.js">
</script>
</head>
<body>
<table align="center" width="960px" cellpadding="0" cellspacing="0" border="0">
<tr><td colspan="2" height="124" valign="top" align="center">
	<object classid="clsidsmilie27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="960" height="124" align="absmiddle">
   <param name="movie" value="flash/banneradmin.swf" />
   <param name="quality" value="high" />
   <embed src="../flash/banneradmin.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="960" height="124" align="absmiddle"></embed>
 	</object>
</td></tr>
<tr><td colspan="2" height="34">	
	<div id="menuadmin">
		<ul id="p7menubar">
			 <li><a class="trigger" href="index.php" target="_self">Trang chủ admin</a></li>
			 <li class="linemenus"></li>					 
		 	 <li><a class="trigger" href="../index.php" target="_self">Trang chủ trường</a>									  	
		  	<li class="linemenus"></li>					 
		  	<li><a class="trigger" href="thongtincanhanadmin.php" target="_self">Thông tin cá nhân</a>			
			<li class="linemenus"></li>					 
		  	<li><a class="trigger" href="../logout.php" target="_self">Thoát</a>	
			<li class="linemenus"></li>	
			<li><a class="trigger">							
				<?
				$nguoidung=$_SESSION["username"];
				if($_SESSION["quyen"]==0){
				$resu23=mysql_query("select * from admin where maadmin='{$nguoidung}'");
				$row23=mysql_fetch_array($resu23);
				?>
					<font color="#FFFFFF">			 
					<? echo "Xin chào : ".$row23["hotendem"]."&nbsp;".$row23["ten"]; ?>
					</font>
				<? }?>	
			</a>							
		  <!--het-->
		</ul>
	</div>	
	</td>
</tr>
<tr>
<td valign="top" align="left" height="750" width="180">
	<!--menu trai-->
		<table align="center" width="100%" border="1" cellpadding="0" cellspacing="0">
		<tr><td valign="middle" height="30">
			<a href="tintuc_admin.php"><img src="../anh/tintuc.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="tintuc_admin.php">Quản lý tin tức</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="loaitin_admin.php"><img src="../anh/loaitin.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="loaitin_admin.php">Quản lý loại tin</a>
		</td></tr>		
		<tr><td valign="middle" height="30">
				<a href="lopctn_admin.php"><img src="../anh/lopctn.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="lopctn_admin.php">Quản lý lớp</a>
		</td></tr>
		
		<tr><td valign="middle" height="30">
			<a href="tobomon_admin.php"><img src="../anh/tobomon.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="tobomon_admin.php">Quản lý tổ giáo viên</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="giaovien_admin.php"><img src="../anh/giaovien.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="giaovien_admin.php">Quản lý giáo viên</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="phuhuynh_admin.php"><img src="../anh/phuhuynh.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="phuhuynh_admin.php">Quản lý phụ huynh</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="hocsinh_admin_1.php"><img src="../anh/user.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="hocsinh_admin_1.php">Quản lý học sinh</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="thoikhoabieu_admin.php"><img src="../anh/thoikhoabieu.png" height="16" width="15" border="0">&nbsp;&nbsp;</a><a href="thoikhoabieu_admin.php">Quản lý thời khóa biểu</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="baiviet_admin.php"><img src="../anh/baiviet.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="baiviet_admin.php">Quản lý bài viết</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="monhoc_admin.php"><img src="../anh/monhoc.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="monhoc_admin.php">Quản lý môn học</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="tailieu_admin.php"><img src="../anh/tailieu.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="tailieu_admin.php">Quản lý tài liệu</a>
		</td></tr>
		<?
			$menu=$_REQUEST["opt"];
			if(($menu=="")||($menu==ko)){
		?>
			<tr><td valign="middle" height="30">
				<a href="?opt=co"><img src="../anh/thuvienanh.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="?opt=co">Quản lý thư viện ảnh</a>
			</td></tr>
		<? }else if($menu==co){?>
			<tr><td valign="middle" height="30">
				<a href="?opt=ko"><img src="../anh/thuvienanh.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="?opt=ko">Quản lý thư viện ảnh</a><br>
				&nbsp;<a href="thuvienanh_admin.php">
					<img src="../anh/1px.gif" height="15" width="16" border="0">
				</a><a href="thuvienanh_admin.php">Thư viện ảnh trường</a><br>
				&nbsp;<a href="thuvienanhlop_admin.php">
					<img src="../anh/1px.gif" height="15" width="16" border="0">
				</a><a href="thuvienanhlop_admin.php">Thư viện ảnh lớp</a>
			</td></tr>
		<? }?>
		
		<tr><td valign="middle" height="30">
			<a href="khoahoc_admin.php"><img src="../anh/khoahoc.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="khoahoc_admin.php">Quản lý khóa học</a>
		</td></tr>
		<!--
		<tr><td valign="middle" height="30">
			<a href="admin_admin.php"><img src="../anh/admin.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="admin_admin.php">Quản lý account</a>
		</td></tr>	
		-->
		<tr><td valign="middle" height="30">
			<a href="admin_sodaubai.php"><img src="../anh/sodaubai.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="sodaubai_admin.php">Quản lý sổ ghi đầu bài</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="admin_lienket.php"><img src="../anh/lienket.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="lienket_admin.php">Quản lý menu</a>
		</td></tr>		
		</table>
</td>
<!--Het menu trai-->
    <td valign="top" align="center"><!-- InstanceBeginEditable name="EditRegion3" -->
	<?
		$matbm=$_REQUEST["matbm"];
		$result=mysql_query("select * from tobomon where matbm='{$matbm}'");
		$r=mysql_fetch_array($result);
	?>
	<h3 align="center"><font color="#CC3333">Quản lý tổ bộ môn</font> </h3>		
	<div class="paneladmin">
			<div class="paneladmin_header"><font color="#003366">THÔNG TIN CHI TIẾT TỔ BỘ MÔN <? echo $r["tentbm"];?></font></div>			
			<form name="f" method="post">
			<TABLE align="center" width="98%" border="1" cellpadding="3" cellspacing="0">
			<?
    	 	$result1=mysql_query("select * from tobomon_giaovien where matbm='{$matbm}'");    	 
    	 	if (mysql_num_rows($result1)<=0)
    	 	{
    	 		echo ("<center>Tổ bộ môn chưa có thành viên nào !</center>");				
    	 	}else {
					?>
				<tr>
					<th align="center">STT</th>
					<th align="center">Họ và tên</th>
					<th align="center">Chức vụ</th>
					<th align="center">Sửa</th>
					<th align="center">Xóa</th>
				</tr>
					<?
					$num_page=ceil(mysql_num_rows($result1)/20);
					$page = $_REQUEST["page"];
					if($page <= 0) $page = 1;
					if($page > $num_page) $page = $num_page;
					$a = ($page - 1)*20;
					$result2 = mysql_query("select * from tobomon_giaovien where matbm='{$matbm}' limit {$a},20");
					$j=0;
					while($r2=mysql_fetch_array($result2)){
					$j++;	 						
			?>																						
					 	<tr>
								<td align="center"><? echo $j;?></td>
					<? if($chon==sua){?>
								<td align="center">
								<input type="hidden" name="tobomonid" id="tobomonid" value="<? echo $matbm;?>">
									<select name="magv" id="magv">
										  <? $result3 = mysql_query("select * from giaovien order by ten");
										  while ($r3 = mysql_fetch_array($result3)){
											echo "<option value={$r3[0]}";
													$result5 = mysql_query("select * from tobomon_giaovien where matbm='{$matbm}' and magv='{$r2["magv"]}'");
														while ($r5=mysql_fetch_array($result5)){
															if ($r5["magv"]==$r3[0]) { echo " selected"; break;
																		}
																				}
											
											echo ">{$r3["hotendem"]}";echo "&nbsp;";echo $r3["ten"];echo "</option>";
											}
										  ?>
									</select>
									
								</td>
								<td align="center">
									<select name="chucvu" id="chucvu">
										<option value="1">Tổ trưởng</option>
										<option value="2">Tổ phó</option>
										<option value="3">Tổ viên</option>
									</select>
								</td>
								<td align="center">
									<input type="submit" name="option" value="save">
								</td>						
								<td align="center"><a href="?option=xoa&matbm=<? echo $r2["matbm"]?>&magv=<? echo $r2["magv"]?>&page=<? echo $page;?>" title="Xóa" onClick="return confirm('Bạn có chắc muốn xóa không ?');">
									<img src="../anh/xoa.png" height="16" width="16" border="0">
								</a></td>	
						<? }else {?>
							<td align="center"><?
									$result3=mysql_query("select * from giaovien where magv='{$r2["magv"]}'");
									$r3=mysql_fetch_array($result3);?>
									<a href="giaovien_admin_detail.php?magv=<? echo $r2["magv"];?>" title="Thông tin giáo viên">
										<? echo $r3["hotendem"]."&nbsp;".$r3["ten"]; ?>
									</a>
								</td>
								<td align="center"><?
									if($r2["chucvu"]==1){
										echo "Tổ trưởng";
									}else if($r2["chucvu"]==2){
										echo "Tổ phó";
									}else {
										echo "Tổ viên";
									}
								?></td>
								<td align="center"><a href="?option=sua&matbm=<? echo $r2["matbm"]?>&magv=<? echo $r2["magv"]?>&page=<? echo $page;?>" title="Sửa">
									<img src="../anh/sua.png" height="16" width="16" border="0">
								</a></td>						
								<td align="center"><a href="?option=xoa&matbm=<? echo $r2["matbm"]?>&magv=<? echo $r2["magv"]?>&page=<? echo $page;?>" title="Xóa" onClick="return confirm('Bạn có chắc muốn xóa không ?');">
									<img src="../anh/xoa.png" height="16" width="16" border="0">
								</a></td>	
						<? }?>
						</tr>													
					<? }?>										 					    	 				
				<tr><td colspan="5">
					<strong>
						<? 
							for($i = 1; $i <=$num_page; $i++)
							if ($i==$page)  echo "&nbsp;Trang&nbsp;".$i."&nbsp;";
							else echo "&nbsp;<a href=?page={$i}&matbm={$matbm}>&nbsp;Trang&nbsp;{$i}</a>&nbsp;";
						?>	
					</strong>	
				</td></tr>
			<?	
    	 	}    	 
    	 ?> 		 
    	 </TABLE>
		 </form>
		 	<?
			$chon2=$_REQUEST["option2"];
				if(($chon2=="")||($chon2=="ko")){
			?>
		 <center><input type="button" value="Thêm mới thành viên" onClick="location.href='?option2=them&matbm=<? echo $matbm;?>'"></center>				
		 	<? }?>
		</div>	
			<?	 	 	
		 	 if($chon2==them){ ?>
			<div class="paneladmin">
			<div class="paneladmin_header"><font color="#003366">THÊM MỚI THÀNH VIÊN <? echo $r["tentbm"];?></font></div>			 							
			<form name="f2" method="post">
			<TABLE align="center" width="98%" border="0" cellpadding="5" cellspacing="0">
				<tr>
					<input type="hidden" name="tobomonid" id="tobomonid" value="<? echo $matbm;?>">
					<th align="right">Họ và tên</th>
					<td align="left">
					<?
						$result4=mysql_query("select * from giaovien order by ten");
						if(mysql_num_rows($result4)<=0){
							echo "Chưa có giáo viên nào trong CSDL !";
						}else {
					?>
							<select name="magv" id="magv">
								<? while($r4=mysql_fetch_array($result4)){?>
									<option value="<? echo $r4["magv"];?>"><? echo $r4["hotendem"]."&nbsp;".$r4["ten"];?></option>
								<? }?>
							</select>
						<? }?>
					</td>															
				</tr>
				<tr>
					<th align="right" width="370">Chức vụ</th>
					<td align="left">
						<select name="chucvu" id="chucvu">
							<option value="1">Tổ trưởng</option>
							<option value="2">Tổ phó</option>
							<option value="3">Tổ viên</option>
						</select>
					</td>
				</tr>
				<tr>
					<td align="center" colspan="2">
						<input type="submit" name="option" value="Add">&nbsp;																				
						<input type="reset" name="reset" value="Reset">&nbsp;
						<input type="button" value="Cancel" onClick="location.href='?option2=ko&matbm=<? echo $matbm;?>'">					
					</td>
				</tr>
			</table>
			
			</form>
		<? }?>
	</div>	
	  		
<!-- InstanceEndEditable --></td>
</tr>
<tr><td colspan="2" height="100" valign="middle" align="center" bgcolor="#999999">Phạm Đức Đóa - Khoa CNTT - Đại học Xây Dựng</td></tr>
</table>
</body>
<!-- InstanceEnd --></html>
